package com.lei.design.strategy;

import com.lei.design.strategy.behavior.fly.FlyBehavior;
import com.lei.design.strategy.behavior.quack.QuackBehavior;
import com.lei.design.strategy.behavior.swim.SwimBehavior;

/**
 * @Author LeiXiaoLei
 * @Date 2022/5/12 16:28
 * @Version 1.0
 */
public abstract class Duck {
    private FlyBehavior flyBehavior;
    private QuackBehavior quackBehavior;
    private SwimBehavior swimBehavior;

    public abstract void display();

    public void performFly(){
        flyBehavior.fly();
    }

    public void performQuack(){
        quackBehavior.quack();
    }

    public void performSwim(){
        swimBehavior.swim();
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    public void setSwimBehavior(SwimBehavior swimBehavior) {
        this.swimBehavior = swimBehavior;
    }
}
